//
//  NextViewController.swift
//  CustomTransition
//
//  Created by CaryaLiu on 2021/10/14.
//

import UIKit

class NextViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
//        navigationController?.delegate = self
        navigationController?.addTransition(.slide(direction: .down, operation: .pop))
    }
}

extension NextViewController: UINavigationControllerDelegate {
    func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationController.Operation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        if operation == .pop {
            return TransitionAnimator.create(with: .slide(direction: .right, operation: .pop))
        }
        return nil
    }
}
